Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exporter/*: eliminate use of .Append() #3861

Merged

Conversation

Aneurysm9
Copy link
Member

Description: Removes use of deprecated .Append() methods.

Link to tracking Issue: open-telemetry/opentelemetry-collector#2488

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
@Aneurysm9 Aneurysm9 requested a review from jpkrohling as a code owner June 22, 2021 17:30
@Aneurysm9 Aneurysm9 requested a review from a team June 22, 2021 17:30
@@ -283,7 +284,8 @@ func TestPushFailedBatch(t *testing.T) {
log := logs.ResourceLogs().At(0)

for i := 0; i < maxBufferSize; i++ {
logs.ResourceLogs().Append(log)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it me, or is the removal of Append going to complicate the API for the consumers? One call is now two calls (AppendEmpty + CopyTo).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We changed to this to not change too much in components, but normally consumers should call AppendEmpty then fill the result instead of returning a metric.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. Previously, a consumer would call:

			logs.Append(log)

Now, they need to do this:

			tgt := logs.AppendEmpty()
			log.CopyTo(tgt)

This does complicate the caller, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually just in this case, Append was not correctly used. Because Append does not do a Copy of the log, so all the entries would point to the same log internal (a.k.a if you change one of the entry it changes all).

But in general the previous use-case was:

log := generateLog()
logs.Append(log)

Now customers will do:

log := fillLog(logs.AppendEmpty())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this one was also used incorrectly then?

From:

				s.Events().Append(event)

To:

				tgt := s.Events().AppendEmpty()
				event.CopyTo(tgt)

If so, the change looks good to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was, but to limit the amount of changes we went the simple path.

@bogdandrutu bogdandrutu merged commit 526d7c3 into open-telemetry:main Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants